﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FXnaInfrastructure
{

    /// <summary>
    /// 提供一个基础的网格类型
    /// 在这里我们规定左下点，为标准原点，向右，向上增加
    /// 在这里我们做一个最简单的均分网格，点在边线上的情况
    /// 我们暂且认为这个网格是没有旋转的
    /// </summary>
    [Serializable]
    public class FGrid
    {

        public FGrid(double rotate, double orgX,double orgY,int nxPt,int nyPt,double xLength,double yLength)
        {

            this._rotateAngle = rotate;


            this._orgX = orgX;
            this._orgY = orgY;


            this._nX = nxPt;

            this._nY = nyPt;

            this._xLength = xLength;
            this._yLength = yLength;






 
        }

     






        private double _rotateAngle;


        /// <summary>
        /// 定义沿Z轴的旋转角
        /// </summary>
        protected double RotateAngle
        {
            get { return _rotateAngle; }
            set { _rotateAngle = value; }
        }





       

        public double XMin
        {
            get { return this._orgX; }

        }
       

        public double YMin
        {
            get { return this._orgY; }

        }

        

        public double XMax
        {
            get { return this._orgX+this._xLength; }

        }
       

        public double YMax
        {
            get { return this._orgY+this._yLength; }

        }





        protected double _xLength;

        protected double _yLength;







        protected int _nX = 2;

        public int NX
        {
            get { return _nX; }
           
        }




        protected int _nY = 2;

        public int NY
        {
            get { return _nY; }

        }



        protected double _orgX;

        public double OrgX
        {
            get { return _orgX; }
            set { _orgX = value; }
        }

        protected double _orgY;

        public double OrgY
        {
            get { return _orgY; }
            set { _orgY = value; }
        }





        #region 方法


        /// <summary>
        /// 返回第i个点的坐标，这里要求返回的是实际的坐标，目前不包含旋转，但以后要求包含
        /// 
        /// </summary>
        /// <param name="i"></param>
        /// <returns></returns>
        public virtual double GetXPos(int i)
        {
            return this._orgX + i * (this._xLength / (this._nX - 1));
 
        }


        public virtual double GetYPos(int j)
        {

            return this._orgY + j * (this._yLength / (this._nY - 1));
 
        }

        #endregion



    }
}
